package top.dark.design.patterns.factory.mymethod;

import java.util.Scanner;

/**
 * Author: Darkn
 * description:
 * Create Time: 2021/4/22 11:23
 */
public class OrderPizza {

    public void orderPizza(){
        do {
            String orderType = getOrderType();
            Pizza pizza = null;
            if (orderType.equals("Greek")) {
                pizza = new GreePizza();
                pizza.setName("希腊披萨");
            } else if (orderType.equals("Chesse")) {
                pizza = new ChessePizza();
                pizza.setName("芝士披萨");
            } else {
                break;
            }
            pizza.prepare();
            pizza.bake();
            pizza.cut();
            pizza.box();
        } while (true);
    }

    public String getOrderType(){
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入您需要订购的披萨编号：");
        String orderType = scanner.nextLine();
        return orderType;
    }
}
